package cn.com.eado.crm.model.net

import androidx.lifecycle.LiveData
import cn.com.eado.crm.m.bean.PostCompany
import cn.com.eado.crm.m.bean.PostCompanyUser
import cn.com.eado.crm.m.db.Company
import cn.com.eado.crm.m.db.CusUser
import cn.com.eado.crm.m.db.EnterpriseInfo
import cn.com.eado.crm.m.db.Institute
import retrofit2.http.*
import okhttp3.RequestBody
import retrofit2.http.Body
import io.reactivex.Flowable
import retrofit2.http.POST



//base url:http://192.168.1.130:8020
interface HttpApi {

    //用户登录
//    @FormUrlEncoded
//    @POST("/app/AppUserInfo")
//    fun userLogin(
//        @Field("Username") Username: String,
//        @Field("UserPassWord") UserPassWord: String,
//        @Field("Mac") mac: String
//    ): LiveData<ApiResponse<String>>

    @FormUrlEncoded
    @POST("/App_Interface/AppUserInfo")  //http://192.168.1.130:8020/App_Interface/AppUserInfo?username=admin&UserPassWord=1
    fun userLogin(
        @Field("username") Username: String,
        @Field("UserPassWord") UserPassWord: String
    ): LiveData<ApiResponse<String>>

    @FormUrlEncoded
    @POST("/App_Interface/CompanyData")
    fun getCompany(
        @Field("CompanyName") CompanyName: String?,
        @Field("GroupName") GroupName: String?,
        @Field("IndustryName") IndustryName: String?,
        @Field("LinkName") LinkName: String?,
        @Field("Address") Address: String?,
        @Field("AreaID") AreaID: String?,
        @Field("UserName") UserName: String?,
        @Field("rows") rows: Int,
        @Field("page") page: Int
    ): LiveData<ApiResponse<Company>>

    @FormUrlEncoded
    @POST("/App_Interface/getCusUser")
    fun getCusUser(
        @Field("CompanyID") CompanyID: String?,
        @Field("CompanyName") CompanyName: String?,
        @Field("CUserName") CUserName: String?,
        @Field("UserName") UserName: String?,
        @Field("rows") rows: Int,
        @Field("page") page: Int
    ): LiveData<ApiResponse<CusUser>>

    @Headers("Content-type:application/json;charset=UTF-8")
    @POST("/Sal_Company/SaveCompany")
    fun saveCompany(@Body body: PostCompany): LiveData<ApiResponse<String>>

//    @FormUrlEncoded
//    @POST("/Sal_Company/CompanyData?Rnum=0.6701391085500479")
//    fun searchCompany(
//        @Field("page") page: Int,
//        @Field("rows") rows: Int
////                   @Field("CompanyName") companyName: String
//    ): LiveData<ApiResponse<Company>>


    @FormUrlEncoded
    @POST("/Sal_Institute/InstituteData")  //string InstituteName, string IndustryName, string LinkName, string Address, string AreaID, string UserName, int rows, int page
    fun getInstitute(
//        @Field("InstituteName") InstituteName: String?,
//        @Field("IndustryName") IndustryName: String?,
//        @Field("LinkName") LinkName: String?,
//        @Field("Address") Address: String?,
//        @Field("AreaID") AreaID: String?,
//        @Field("UserName") UserName: String?,
        @Field("page") page: Int,
        @Field("rows") rows: Int
    ): LiveData<ApiResponse<Institute>>

    @Headers("Content-type:application/json;charset=UTF-8")
    @POST("/Sal_Company/SaveCompany")
    fun saveInstitute(@Body body: PostCompany): LiveData<ApiResponse<String>>

    @FormUrlEncoded
    @POST("/Sal_Institute")   //http://192.168.1.130:8020/Sal_Institute/InstituteData?rom=0.715639891913387
    fun searchInstitute(
        @Field("page") page: Int,
        @Field("rows") rows: Int
//                   @Field("CompanyName") companyName: String
    ): LiveData<ApiResponse<Institute>>






}
